package com.craiglarman.monopoly.domain;

import java.util.ArrayList;
import java.util.List;

public class Game {

	private static final int _1 = 1;
	private int numOfRounds;
	private int currentRound;
	private Board myBoard;
	private Die die1;
	private Die die2;
	private List<Player> players;
	public static final int MAXROUND = 10;
	private String output;

	public Game() {
		currentRound = _1;
		numOfRounds = MAXROUND;
		myBoard = new Board();
		die1 = new Die();
		die2 = new Die();
		output="";


	}
	
	
	public Game(Die die1, Die die2) {
		currentRound = _1;
		numOfRounds = MAXROUND;
		myBoard = new Board();
		output="";
		
		this.die1 = die1;
		this.die2 = die2;

		Player player1 = new Player(myBoard, die1, die2);
		players.add(player1);

		Player player2 = new Player(myBoard, die1, die2);
		players.add(player2);

	}

	public void setNumOfRounds(int numOfRounds) {
		this.numOfRounds = numOfRounds;
	}
	public int getNumOfRounds() {
		return numOfRounds;
	}

	public int getCurrentRound() {
		return currentRound;
	}

	public void setCurrentRound(int currentRound) {
		this.currentRound = currentRound;
	}

	public List<Player> getPlayers() {
		return players;
	}

	public void setPlayers(List<Player> players) {
		this.players = players;
	}

	public void playRound() {
		currentRound++;
		for (Player player : players) {
			player.takeTurn();
			output = output + player.getDiceTotal();
		}
	}

	public void play(int roundsToPlay, int numberOfPlayers) {
		numOfRounds=roundsToPlay;
		players = new ArrayList<Player>(numberOfPlayers);
		
		for(int p=0; p < numberOfPlayers; p++){
			players.add(new Player(myBoard, die1, die2));
		}
		for (int i = 0; i < roundsToPlay; i++) {
			playRound();
		}
	}

	public String getOutput() {
		return output;
	}

	public void setOutput(String output) {
		this.output = output;
	}

}
